package org.jeecg.modules.scm.api;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.scm.entity.ScmCusInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@FeignClient(value = "jeecg-scm/cus_info/scmCusInfo")
@Component
public interface ScmCusInfoAPI {

    /**
     * 根据客户号获取客户信息
     * @param cusNo
     * @return
     */

    @GetMapping("/queryById")
    Result<ScmCusInfo> queryById(@RequestParam(name = "cusNo", required = true) String cusNo);

    /**
     * 根据客户名称获取客户号
     * @param cusName
     * @return
     */

    @GetMapping("/getNoByName")
    public Result<?> getNoByName(@RequestParam(name="cus_name",required=true) String cusName);

    /**
     * 通过客户号获取客户名称
     * @param cusNo
     * @return
     */
    @GetMapping(value = "/getNameByNo")
    public Result<?> getNameByNo(@RequestParam(name="cus_no",required=true) String cusNo);


    /**
     * 分页列表查询
     * @param scmCusInfo
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/list")
    public Result<?> queryPageList(@RequestParam ScmCusInfo scmCusInfo,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req);

    /**
     * 添加客户
     * @param scmCusInfo
     * @return
     */
    @PostMapping(value = "/add")
    public Result<?> add(@RequestBody ScmCusInfo scmCusInfo) ;

    /**
     * 编辑客户
     * @param scmCusInfo
     * @return
     */

    @PutMapping(value = "/edit")
    public Result<?> edit(@RequestBody ScmCusInfo scmCusInfo);

    /**
     * 通过cus_no删除
     * @param cus_no
     * @return
     */

    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestParam(name="cus_no",required=true) String cus_no);

    /**
     * 批量删除
     * @param ids
     * @return
     * **/
    @DeleteMapping(value = "/deleteBatch")
    public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids);

    /**
     * 通过指定字段查询
     * @param type
     * @param value
     * @return
     */
    @GetMapping(value = "/queryByField")
    public Result<?> queryByField(@RequestParam(name="type",required=true) String type,
                                  @RequestParam(name="value",required=true) String value);

    /**
     * 通过多字段查询
     * @param scmCusInfo
     * @return
     */
    @PutMapping(value = "/queryByFields")
    public Result<?> queryByFields(@RequestBody Map<String,Object> scmCusInfo);

    /**
     * 	模糊查询客户
     * @param type
     * @param value
     * @return
     * */
    @GetMapping(value = "/fuzzyQuery")
    public Result<?> fuzzyQuery(
            @RequestParam(name="type",required=true) String type,
            @RequestParam(name="value",required=true) String value
    );


}
